﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccess.IService;
using System.Data;
using Utility;
using System.Collections;
using System.Data.SqlClient;

namespace DataAccess.Service
{
     public class StuCardService:IStuCardService
    {
       //2个
        public string selectStuCardInform(string studentId)
        {
            string stuCardInfor = string.Empty;
            string commandText = "select stuCardId,amount from StudentCard where stuId=@studentId";
            SqlParameter[] paras = new SqlParameter[]
            {
              new SqlParameter("studentId", studentId)
            };
            SqlDataReader sdReader = SQLHelper.ExecuteReader(commandText, paras);
            if (sdReader.Read())
            {
                stuCardInfor = Convert.ToString(sdReader["stuCardId"]);
                stuCardInfor = stuCardInfor + Convert.ToString(sdReader["amount"]);

            }
            return stuCardInfor;
        }



        public bool updateStuCardInfor(decimal amount, string stuId)
        {
            bool result = false;
            string commandText = "update StudentCard set amount=amount+@amount where stuId=@studentId";
            SqlParameter[] paras = new SqlParameter[]
            {
               new SqlParameter("amount", amount),
               new SqlParameter("studentId", stuId)
            };
            if (SQLHelper.ExecuteNonQuery(commandText, paras) > 0)
            {
                result = true;
            }
            return result;
                
        }
    }
}
